package servlet;

/**
 * @Description TODO
 * @Author zzj
 * @Date 2020/8/5 15:42
 */

import pojo.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/selectList")
public class UserServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserDao userDao = new UserDaoImp();
        List<User> users = userDao.SelectAll();
        // HttpServletRequest 保存数据
        req.setAttribute("users", users);
        // 视图转发
        req.getRequestDispatcher("/main.jsp").forward(req, resp);
    }
}

